var path = require('path')
var webpack = require('webpack')
var config = require('./webpack.base.config')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

config.output.publicPath = path.join('./dist/')
config.output.filename = '[name].[hash].js' // 带hash值的入口js名称
config.output.chunkFilename = '[name].[hash].chunk.js' // 带hash值的路由js名称

config.plugins = (config.plugins || []).concat([
	new ExtractTextPlugin({
		filename: '[name].[hash].css',
		disable: false,
		allChunks: true
	}),
	new webpack.optimize.CommonsChunkPlugin({
		name: 'vendors',
		filename: 'vendors.[hash].js'
	}),
	new webpack.DefinePlugin({
		'process.env': {
			NODE_ENV: '"production"'
		}
	}),
	// 压缩文件
	new webpack.optimize.UglifyJsPlugin({
		compress: {
			warnings: false
		}
	}),
	new HtmlWebpackPlugin({
		filename: '../index.html',
		template: './src/template/index.ejs',
		inject: false
	})
])

module.exports = config
